package com.zn.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zn.Vo.CardAndCareerVo;
import com.zn.bean.Card;
import com.zn.service.CardService;
import com.zn.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 码农小周
 * @since 2023-05-12
 */
@Slf4j
@Api(tags = "名片相关操作")
@RestController
@RequestMapping("/card")
public class CardController {

    @Resource
    private CardService cardService;

    /**
     * 查询名片信息
     * @param page
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "查询名片信息")
    @GetMapping("/pageInfo")
    public Result<Page<CardAndCareerVo>> pageInfo(Long page, Long pageSize, String name) {
        return cardService.pageInfo(page,pageSize,name);
    }

    /**
     * 新增名片信息
     * @param
     * @return
     */
    @ApiOperation(value = "新增名片信息")
    @PostMapping("/addCard")
    public Result<String> addCard(@RequestBody Card card) {

        return cardService.addCard(card);
    }

    /**
     * 修改名片信息
     * @param card
     * @return
     */
    @ApiOperation(value = "修改名片信息")
    @PostMapping("/editCard")
    public Result<String> editCard(@RequestBody Card card) {

        return cardService.editCard(card);
    }


    /**
     * 删除名片信息
     * @param cardId
     * @return
     */
    @ApiOperation(value = "删除名片信息")
    @GetMapping("/delCard")
    public Result<String> delCard(Long cardId) {
        return cardService.delCard(cardId);
    }

    /**
     * 上传表格数据
     * @param cardAndCareerVoList
     * @return
     */
    @PostMapping ("/uploadExcel")
    @ApiOperation(value = "上传表格数据")
    public Result<String> uploadExcel(@RequestBody List<CardAndCareerVo> cardAndCareerVoList){

        return cardService.uploadExcel(cardAndCareerVoList);
    }
}
